//
//  MyMain.java
//  ics314-calendar
//
//  Created by JinHao Chen on 7/24/14.
//  Copyright (c) 2014 JinHao Chen. All rights reserved.
//



import java.io.*;
public class MyMain {
	
	private void init(String classification, String priority, String dt_start, String dt_end, String summary, String description) {
		FileOutputStream fos;	
		String s = String.format(     
			       "BEGIN:VCALENDAR\n"+
			       "PRODID:-//Apple Inc.//Mac OS X 10.9.4//EN\n" +
			       "VERSION:2.0\n"+
			       "BEGIN:VEVENT\n"+
			       "GEO:37.386013;-122.082932\n" + // This is just an example, need to change
			       "CLASS:%s\n" +
			       "PRIORITY:%s\n" +
			       "DTSTART:%s\n"+
			       "DTEND:%s\n"+
			       "SUMMARY:%s\n"+
			       "DESCRIPTION:%s\n"+
			       "END:VEVENT\n"+
			       "END:VCALENDAR", classification, priority, dt_start, dt_end, summary, description);

		try {
			fos = new FileOutputStream("testing.ics");  
			OutputStreamWriter osw=new OutputStreamWriter(fos);
			BufferedWriter bw=new BufferedWriter(osw);
			bw.write(s);
			bw.flush();
			bw.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	/**
	 * @param String classification, priority, dt_start, dt_end, summary, description;
	 */
	public static void main(String[] args) {
		try {
			String classification, priority, dt_start, dt_end, summary, description;
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Please Input the Classification");
			classification= br.readLine();
			System.out.println("Please Input the Priority ( 0-10 )");
			priority = br.readLine();
			System.out.println("Please Input the START of date and time(Example: 2014-07-13 11:56:31 is 20140713T115631Z)");
			dt_start = br.readLine();
			System.out.println("Please Input the END of date and time(Example: 2014-07-13 11:56:31 is 20140713T115631Z)");
			dt_end = br.readLine();
			System.out.println("Please Input the summary");
			summary = br.readLine();
			System.out.println("Please Input the description");
			description  = br.readLine();
			
			new MyMain().init(classification,priority,dt_start,dt_end,summary,description);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
